import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: 祺诺
 * @Name; xqf
 * @Date: 2020/12/24 19:44
 */
public class CookieUtils {
    public static Cookie findCookie(HttpServletRequest req,String cookiName){
            //获取所有的cookie
        Cookie[] cookies = req.getCookies();
        if(cookies!=null){
            //遍历cookie 寻找 需要的cookie键值对
            for (Cookie c : cookies) {
                if(c.getName().equals(cookiName)){
                    //找到了返回
                    return c;
                }
            }
        }
        //没找到返回null
        return  null;
    }
}
